package com.wbp.cms.qatest.dao;

import java.util.List;

import javax.annotation.Resource;

import org.junit.Test;

import com.wbp.cms.client.common.Page;
import com.wbp.cms.client.common.domain.DictionaryDO;
import com.wbp.cms.client.common.query.DictionaryQuery;
import com.wbp.cms.core.dao.DictionaryDAO;
import com.wbp.cms.qatest.BaseTest;


/**
 * @Description: 
 * @Department:
 * @author andy.lhc
 * @date 2016年3月11日 下午4:32:56 
 */
public class DictionaryDAOTest extends BaseTest{

  @Resource
  private DictionaryDAO  dictionaryDAO ;
  
  @Resource
  private com.wbp.cms.core.dao.base.DictionaryDao  dictionaryDao2 ;
  
  @Test
  public  void  test_insert01(){
    
    DictionaryDO  dictionaryDO =new DictionaryDO();
    dictionaryDO.setTableName("Product");
    dictionaryDO.setTableDesc("产品"); 
    dictionaryDO.setAttributeName("ProfitType");
    dictionaryDO.setAttributeDesc("收益类型"); 
    System.out.println( dictionaryDAO.insert(dictionaryDO)>0 )  ;
  }
  
  @Test
  public  void  test_insert01_2(){
    
    DictionaryDO  dictionaryDO =new DictionaryDO();
    dictionaryDO.setTableName("Product2");
    dictionaryDO.setTableDesc("产品2"); 
    dictionaryDO.setAttributeName("ProfitType2");
    dictionaryDO.setAttributeDesc("收益类型2"); 
    System.out.println( dictionaryDao2.insert(dictionaryDO)>0 )  ;
  }
  
  @Test
  public  void  test_insert02(){
    
    DictionaryDO  dictionaryDO =new DictionaryDO();
    dictionaryDO.setTableName("Product");
    dictionaryDO.setTableDesc("产品"); 
    dictionaryDO.setAttributeName("status");
    dictionaryDO.setAttributeDesc("状态"); 
    System.out.println( dictionaryDAO.insert(dictionaryDO)>0 )  ;
  }
  
  @Test
  public  void  test_insert03(){
    
    DictionaryDO  dictionaryDO =this.dictionaryDAO.load(2L) ;
    DictionaryDO d =new DictionaryDO();
    d.setTableName("Product");
    d.setTableDesc("产品"); 
    d.setAttributeName("status");
    d.setAttributeDesc("状态"); 
    d.setParentId(dictionaryDO.getId());
    d.setValue(3);
    d.setCode("End");
    d.setDescription("结束");
    System.out.println( dictionaryDAO.insert(d)>0 )  ;
  }
  
  @Test
  public  void  test_query(){
      List<DictionaryDO>  list = this.dictionaryDAO.queryChildDictionary(2L) ;
      System.out.println("size: " + list.size() ); 
      System.out.println("list: " + list );
  }
  
  @Test
  public  void  test_query_2(){
      DictionaryDO  list = this.dictionaryDao2.queryEntityById(104326L);
      System.out.println("list: " + list );
      DictionaryQuery  dq = new DictionaryQuery();
      dq.setId(104326L);
      List<DictionaryDO> list2 = dictionaryDao2.queryList(dq) ;
      System.out.println("list2.size:"+list2.size());
      @SuppressWarnings("unchecked")
	Page<DictionaryDO> p = dictionaryDao2.queryByPage(dq) ;
      System.out.println("page :"+p);
      System.out.println("page list:"+p.getRecordList().size());
      
      DictionaryDO  dd  = dictionaryDao2.queryEntity(dq) ;
      System.out.println("dd : "+ dd);
  }
  
  
}
